Developer Documentation
PATH  Mac OS X Documentation > Developer Tools > Mac OS X Assembler Guide


Previous | Contents | Next

Extended Instruction Mnemonics & Operands

Branch Mnemonics

The PowerPC processor family supports a rich variety of extended mnemonics for its three conditional branch operators: bc , bclr , and bcctr . Normally, the condition and the nature of the branch are specified by numeric operands, but with the extended mnemonics, these numeric operands are determined by the assembler from the mnemonic used.

Conditional branches can alter the contents of the Count Register ( ctr ), and can take effect based on the resulting value in the Count Register, and on whether a specified condition is true or false. The first table below summarizes the extended mnemonics for branches that affect the Count Register, while the second summarizes additional mnemonics for branches on true and false conditions that don't affect the Count Register. The effect of the branch is given on the left. The first four columns of each table are for branches where the Link Register bit in the instruction is clear (not set); the remaining columns are for branches where the Link Register bit in the instruction is set. Each set of four columns gives mnemonics for relative and absolute branches, and for branches to the Link Register or the Count Register.

Branch Type
LR not set
LR set

 

bc

bca

bclr

bcctr

bcl

bcla

bclrl

bcctrl

 

Rel.

Abs.

to LR

to CTR

Rel.

Abs.

to LR

to CTR

unconditional

b

ba

blr

bctr

bl

bla

blrl

bctrl

if condition true

bt

bta

btlr

btctr

btl

btla

btlrl

btctrl

if condition false

bf

bfa

bflr

bfctr

bfl

bfla

bflrl

bfctrl

decrement CTR, branch if CTR non-zero

bdnz

bdnza

bdnzlr

-

bdnzl

bdnzla

bdnzlrl

-

Decrement CTR, branch if CTR non-zero and condition true      

bdnzt

bdnzta

bdnztlr

-

bdnztl

bdnztla

bdnztlrl

-

Decrement CTR, branch if CTR non-zero and condition false

bdnzf

bdnzfa

bdnzflr

-

bdnzfl

bdnzfla

bdnzflrl

-

Decrement CTR, branch if CTR zero

bdz

bdza

bdzlr

-

bdzl

bdzla

bdzlrl

-

Decrement CTR, branch if CTR zero and condition true

bdzt

bdzta

bdztlr

-

bdztl

bdztla

bdztlrl

-

Decrement CTR, branch if CTR zero and condition false

bdzf

bdzfa

bdzflr

-

bdzfl

bdzfla

bdzflrl

-

The mnemonics in the table above encode specific values for the BO field of the non-extended operators. The BO field controls the effect on the Count Register and on what type of condition the branch is to be taken. The BI field, which controls the specific condition to consider, must still be given, as the first operand. The value of this operand indicates which field of the Condition Register to use, and which bit within that field to consider.

The Condition Register has 8 fields, numbered 0 to 7, each of which contains a bit for conditions less than , greater than , equal , and summary overflow or unordered . The numeric value for field n of the Condition Register is 4* n , and the numeric values for the conditions are 0, 1, 2, and 3, respectively. The following symbols may be used instead of numbers:

Symbol      
Value      
Meaning

lt

0

Less than

gt

1

Greater than

eq

2

Equal

so

3

Summary overflow

un

3

Unordered (after floating-point comparison)

cr0

0

Condition Register field 0

cr1

4

Condition Register field 1

cr2

8

Condition Register field 2

cr3

12

Condition Register field 3

cr4

16

Condition Register field 4

cr5

20

Condition Register field 5

cr6

24

Condition Register field 6

cr7

28

Condition Register field 7

For example, a branch if condition true for the condition greater than in Condition Register field 3 could be written in any of these ways:

bt cr3+gt,target bt 12+1,target bt 13,target

Omitting the symbol for either the Condition Register field or the condition is permitted, as long as the result of the expression is a number from 0-31:

bt gt,target ; uses field 0 bt cr3,target ; branches on less than in field 3 bt 13,target ; branches on less than in field 3

Another way to specify these conditions is to use the extended mnemonics in the second table, below. These mnemonics encode the actual condition on which to take a branch. The second and third letters of the mnemonic indicate that condition:

Code      
Meaning

lt

Less than

le

Less than or equal

eq

Equal

ge

Greater than or equal

gt

Greater than

nl

Not less than

ne

Not equal

ng

Not greater than

so

Summary overflow

ns

Not summary overflow

uo

Unordered (after floating-point comparison)

nu

Not unordered (after floating-point comparison)

Some condition codes, such as le , are actually more compact codes for a false result on the opposite condition in the set of conditions given previously (for example, le is equivalent to if condition false on condition greater than ).

By default, the extended mnemonics in the table below used Condition Register field 0. An optional first operand can be given to specify another field, in either numeric form or as a symbol of the form cr n . For example:

bgt target ; branch if cr0 shows "greater than" bgt cr3,target ; branch if cr3 shows "greater than"

Branch Type
LR not set
LR set
bc
bca
bclr
bcctr
bcl
bcla
bclrl
bcctrl
Rel.      
Abs.      
to LR      
to CTR      
Rel.      
Abs.      
to LR      
to CTR      

less than

blt

blta

bltlr

bltctr

bltl

bltla

bltlrl

bltctrl

less than or equal

ble

blea

blelr

blectr

blel

blela

blelrl

blectrl

equal

beq

beqa

beqlr

beqctr

beql

beqla

beqlrl

beqctrl

greater than or equal

bge

bgea

bgelr

bgectr

bgel

bgela

bgerl

bgectrl

greater than

bgt

bgta

bgtlr

bgtctr

bgttl

bgla

bgtlrl

bgtctrl

not less than

bnl

bnla

bnllr

bnlctr

bnll

bnlla

bnllrl

bnlctrl

not equal

bne

bnea

bnelr

bnectr

bnel

bnela

bnelrl

bnectrl

not greater than

bng

bnga

bnglr

bngctr

bngl

bngla

bnglrl

bngctrl

summary overflow

bso

bsoa

bsolr

bsoctr

bsol

bsola

bsolrl

bsoctrl

not summary overflow      

bns

bnsa

bnslr

bnsctr

bnsl

bnsla

bnslrl

bnsctrl

unordered

bun

buna

bunlr

bunctr

bunl

bunla

bunlrl

bunctrl

not unordered

bnu

bnua

bnulr

bnuctr

bnul

bnula

bnulrl

bnuctrl


Mac OS X Assembler Reference: PowerPC Addressing Modes and Assembler Instructions

Previous | Contents | Next